const generate = () => {
    let bar = document.createElement('div')
    bar.id = 'global_loading'
    bar.style.display = 'none'
    document.body.append(bar)
    return bar
}

const bar = document.getElementById('global_loading') || generate()

declare interface LoadingBar {
    bar: HTMLElement,
    start: () => void,
    end: () => void
}

export default {
    bar: bar,
    start: (): void => {
        bar.style.display = 'block'
    },
    end: (): void => {
        bar.style.display = 'none'
    }
}
